Micron Document
welo git mirrors

Node / public / rns-proxy / commits / 556a310

Commit 556a310cf54a84095e4c7fa5a04c3897b704460c


Parents : 872a7ce
Author : welo | main nixos computer <empty@empty.com>
Date : 2026-07-14T19:34:32+01:00

added more instructions and reworded docs a little and changed the tcp stream to NODELAY for reduced latency at the cost of some overhead

Changes

7 files changed, 27 insertions(+), 24 deletions(-)

M src/cli.rs +12 -3
M src/client.rs +1 -2
M src/mux.rs +5 -5
M src/relay.rs +2 -3

Diff

diff --git a/src/cli.rs b/src/cli.rs
index 75cfc06..14b8f11 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -34,33 +34,42 @@ pub enum Commands {
#[arg(short, long, default_value = "127.0.0.1:1080")]
listen: String,
},
+ /// Connects to localhost ports of the server (Port forwarding)
Connect {
+ /// RNS destination hash (hex)
#[arg(short, long)]
destination: String,
- // server to client ports.
+ /// connects udp ports, can be specified as just the port number or as SERVER_PORT:CLIENT_PORT. Multiple of this flag can be specified
#[arg(short, long, value_parser = port_parser)]
udp_port: Vec<(u16,u16)>,
+ /// connectcs tcp ports, can be specified as just the port number or as SERVER_PORT:CLIENT_PORT. Multiple of this flag can be specified
#[arg(short, long, value_parser = port_parser)]
tcp_port: Vec<(u16,u16)>,
+ /// shorthand for connecting to both udp and tcp, can be specified as just the port number or as SERVER_PORT:CLIENT_PORT. Multiple of this flag can be specified
#[arg(short, long, value_parser = port_parser)]
both_port: Vec<(u16,u16)>, // both udp and tcp
},
+ /// Exposes a SOCKS5 proxy that only allows clients to connect to specified localhost ports.
Forward {
#[arg(long, value_name = "PATH")]
+ /// Path to the identity file for persistent server address.
+ /// Defaults to ~/.reticulum/rns_proxy_identity
identity_file: Option<String>,
#[arg(short, long)]
+ /// allow connecting to localhost udp port for any client accessing this destination. Multiple of this flag can be specified
udp_port: Vec<u16>,
#[arg(short, long)]
+ /// allow connecting to localhost tcp port for any client accessing this destination. Multiple of this flag can be specified
tcp_port: Vec<u16>,
#[arg(short, long)]
- both_port: Vec<u16>, // both udp and tcp
- }
+ /// allow connecting to localhost tcp and udp port for any client accessing this destination. Multiple of this flag can be specified
+ both_port: Vec<u16>, }
}

diff --git a/src/client.rs b/src/client.rs
index 9278366..18d0986 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -453,11 +453,10 @@ async fn handle_tcp_connect(
}
};
+ _=stream.set_nodelay(true); // slightly more overhead but this means slightly less delay and the tcp stream is less slightly to time out.
info!("[{}] - > {}:{}, fully connected to", sid, host, port);
- // Data relay (shared implementation)
- // relay_bidirectional_tcp(sid, stream, mux, session_rx).await;
return Some(stream)
} else {
return None;

diff --git a/src/forwarding.rs b/src/forwarding.rs
index dc77032..672fd2f 100644
--- a/src/forwarding.rs
+++ b/src/forwarding.rs
@@ -8,15 +8,12 @@
//! you send to it get forwarded to the remote server to the remote socket. allowing you to directly
//! connect an application to that port and have it be connected to the remote server.
//!
-//! rns-proxy open-port -U 43 -u 80 443
-//! rns-proxy forward -U 43:43 -u 80:80 443:443
+//! rns-proxy forward -u 43 -t 80
+//! rns-proxy connect -U 43:43 -u 80:80 443:443
//!
-//! rns-proxy open-port/forward by default only forwards/connects to tcp
-//! -u flag attempts does both udp and tcp
-//! -U flag means udp only
-//!
-//!
-//!
+//! -t flag means onyl tcp is connected to
+//! -u flag means udp only
+//! -b flag attempts does both udp and tcp
use std::{net::{Ipv4Addr, SocketAddr}, sync::Arc};
@@ -31,7 +28,7 @@ use crate::{client::{connect_tcp_server_side, udp_bind_connect}, mux::MuxHandle,
pub enum PortType {
Tcp,
Udp,
- TcpUdp, // both
+ TcpUdp,
}
#[derive(Clone, Debug)]

diff --git a/src/frame.rs b/src/frame.rs
index 5ae4e46..cb7dd7a 100644
--- a/src/frame.rs
+++ b/src/frame.rs
@@ -10,8 +10,6 @@
use std::fmt;
-use log::info;
-
use crate::frame::FrameDecodeState::{DecodingFailed, MoreDataRequired};
// ---------------------------------------------------------------------------

diff --git a/src/mux.rs b/src/mux.rs
index f4dbe21..47e1f12 100644
--- a/src/mux.rs
+++ b/src/mux.rs
@@ -18,7 +18,7 @@ use std::collections::HashMap;
use std::sync::Arc;
use tokio::sync::{Mutex};
-use log::{debug, error, info, warn};
+use log::{error, info, warn};
use rns_core::constants::LINK_MDU;
use rns_net::{LinkId, RnsNode};
use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender, unbounded_channel};
@@ -38,7 +38,7 @@ pub struct MuxHandle {
// #[ignore(unused_attributes)]
struct MuxInner {
- node: Arc<RnsNode>,
+ _node: Arc<RnsNode>, // we migth use this someday but right now the run_link_sender thread is the only thing that uses it.
link_id: Arc<Mutex<Option<LinkId>>>,
sessions: Mutex<HashMap<u32, tokio::sync::mpsc::UnboundedSender<Frame>>>,
next_sid: Mutex<u32>,
@@ -85,7 +85,7 @@ impl MuxHandle {
let link_id = Arc::new(Mutex::new(None));
Self {
inner: Arc::new(MuxInner {
- node: node.clone(),
+ _node: node.clone(),
link_id: link_id.clone(),
sessions: Mutex::new(HashMap::new()),
next_sid: Mutex::new(0),
@@ -148,8 +148,8 @@ impl MuxHandle {
/// multiple different sids from sending at the same time and scrambling packets
pub async fn send_frame(&self, frame: &Frame) {
let encoded = frame.encode();
- self.inner.data_sender_buf.send(encoded);
- // info!("test print {:?}", self.inner.data_sender_buf.send(encoded));
+ _=self.inner.data_sender_buf.send(encoded);
+ // pretty much should never error so we don't care.
}

diff --git a/src/relay.rs b/src/relay.rs
index bc1ff24..68a2461 100644
--- a/src/relay.rs
+++ b/src/relay.rs
@@ -1,7 +1,6 @@
-//! Bidirectional TCP ↔ RNS relay — used by both client and server sessions.
+//! Bidirectional TCP?UDP ↔ RNS relay — used by both client and server sessions.
//!
-//! Note 1, idk where to put this but the buffer has to be bigger than 64k as v
-//! orginally was 4096 but occasionally there would be packets
+//! Dev Note 1, idk where to put this but the buffer could be smaller than
use std::net::Ipv4Addr;
use std::sync::Arc;

diff --git a/src/server.rs b/src/server.rs
index 86d3fe7..0005197 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -227,6 +227,7 @@ async fn handle_server_session_tcp(
}
};
+ _=stream.set_nodelay(true); // we can spare the overhead for less delay RNS side cause it's already not great.
// Signal success
mux.send(FrameType::ConnectOk, sid, Vec::new()).await;

Served by rngit 1.5.1 - Generated in 0.11s